/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ui.gui.documents.toolbox;

import java.awt.Component;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import ui.gui.documents.IconifiableItem;

/**
 *
 * @author stephane
 */
public class WorkspaceTreeRender extends DefaultTreeCellRenderer {
    private static final long serialVersionUID = 1L;


    public WorkspaceTreeRender() {
       
    }

    @Override
    public Component getTreeCellRendererComponent(JTree tree, Object value,boolean sel,boolean expanded, boolean leaf,int row, boolean hasFocus) 
    {
        super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
        IconifiableItem item =null;
       if (value != null && value instanceof IconifiableItem) {
    	   item = (IconifiableItem)value;
    	   
       }
       else if (value != null && value instanceof DefaultMutableTreeNode) {
    	   item = (IconifiableItem)((DefaultMutableTreeNode)value).getUserObject();
       }
        setIcon(item.getIcon());
       
        return this;
    }
}
